const cp = require('cp');
require('./page.css');
let moduleExport = {};
let data = {
  org: {
    id: '',
    title: '',
    address: '未填写',
    brief: '未填写',
    founduname: '',
    createtime: '',
  },
  contact: {
    id: '',
    realname: '',
    mobile: '',
    email: '未填写',
    addressname: '未填写',
    idcardno: '未填写',
    zhimascore: '未授权',
  },
  credit: {
    type: 1,
  },
  obj_edit: {
    org: true,
    contact: false,
    credit: false,
  },
};
const OBJ_STATUS = {
  0: {
    color: 'f-c-gray',
    title: '未提交审核',
    tips: 'u-tips-warning',
    tipstxt: '您的资料还未提交审核，请完善后尽快提交',
  },
  1: {
    color: 'f-c-green',
    title: '资料审核中',
    tips: 'u-tips-warning',
    tipstxt: '您的资料已提交审核，将在1-5个工作日内审核完成，请耐心等待',
  },
  2: {
    color: 'f-c-green',
    title: '审核通过',
    tips: 'u-tips-success',
    tipstxt: '您的资料已通过审核',
  },
  3: {
    color: 'f-c-red',
    title: '审核失败',
    tips: 'u-tips-danger',
    tipstxt: '您的资料被驳回，请尽快修改后重新提交',
  },
};
let vm = avalon.define({
  $id: 'mc_step1_view',
  status: -1,
  data: data,
  formatTime: (time, type, sec) => {
    return cp.formatTime(time, type, sec);
  },
  getStatus: type => {
    switch (vm.status) {
      case -1:
        return OBJ_STATUS[0][type];
      default:
        return OBJ_STATUS[vm.status][type];
    }
  },
  init: () => {
    cp.ajaxUrl({
      controller: 'shopskt',
      cmd: 'com.rel.porg.pb.shop_sel_audit_info_req',
      data: {},
      success: res => {
        for (let i in vm.data.org) {
          if (res.org[i]) {
            vm.data.org[i] = res.org[i];
          }
        }
        for (let i in vm.data.contact) {
          if (res.accaddr[i]) {
            vm.data.contact[i] = res.accaddr[i];
          }
        }
        for (let i in vm.data.contact) {
          if (res.audit[i]) {
            vm.data.contact[i] = res.audit[i];
          }
        }
        if (!res.audit) {
          vm.status = -1;
        } else {
          vm.status = res.audit.status;
        }
      },
      fail: res => {
        cp.layerMsg(res.desc);
      },
    });
  },
});
vm.init();
moduleExport.content = require('./content.html');
moduleExport.vm = vm;
module.exports = moduleExport;
